#ifndef __Y64_PRINTK_H__
#define __Y64_PRINTK_H__

#include <stdarg.h>
#include "font.h"

#define ZEROPAD     1           /* pad with zero */
#define SIGN        2           /* unsigned/signed long */
#define PLUS        4           /* show plus */
#define SPACE       8           /* space if plus */
#define LEFT        16          /* left justified */
#define SPECIAL     32          /* 0x */
#define SMALL       64          /* use 'abcdef' instead of 'ABCDEF' */

#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')

#define DO_DIV(n,base) ({ \
int __res; \
__asm__("divq %%rcx":"=a" (n),"=d" (__res):"0" (n),"1" (0),"c" (base)); \
__res; })

// 预定义颜色
#define WHITE       0x00ffffff
#define BLACK       0x00000000
#define RED         0x00ff0000
#define ORANGE      0x00ff8000
#define YELLOW      0x00ffff00
#define GREEN       0x0000ff00
#define BLUE        0x000000ff
#define INDIGO      0x0000ffff      // 靛
#define PURPLE      0x008000ff

extern unsigned char g_font_ascii[256][16];
extern char g_buf[4096];

typedef struct {
    int x_res;
    int y_res;

    int x_pos;
    int y_pos;

    int x_char_size;
    int y_char_size;

    unsigned int *FB_addr;
    unsigned long FB_length;
} st_position;
extern st_position g_pos;

void putchar(unsigned int *fb, int x_size, int x, int y, unsigned int fr_color, unsigned int bk_color, unsigned char font);

static char *number(char *str, long num, int base, int size, int precision, int type);

int skip_atoi(const char **s);

int vsprintf(char *buf,const char *fmt, va_list args);

int color_printk(unsigned int fr_color, unsigned int bk_color, const char *fmt, ...);

void frame_buffer_init();

#endif
